﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Runtime.Remoting.Messaging;

using DAL;
using Model;

namespace BLL
{
    /// <summary>
    /// 设备 業務類
    /// </summary>
    public class DeviceBLL : BaseBLL<Model.Device>
    {
        /// <summary>
        /// 子类数据访问类对象
        /// </summary>
        DeviceDAL childDAL = null;

        #region 重写父类的抽象方法
        /// <summary>
        /// 重写父类的抽象方法
        /// </summary>
        protected override void SetDAL()
        {
            childDAL = new DAL.DeviceDAL();
            dal = childDAL;//为父类变量赋值
        }
        #endregion

        #region 當前類業務類對象
        /// <summary>
        /// 當前類業務類對象
        /// </summary>
        public static DeviceBLL CurrBll
        {
            get
            {
                DeviceBLL bll = CallContext.GetData(typeof(DeviceBLL).Name) as DeviceBLL;
                if (bll != null)
                {
                    return bll;
                }
                else
                {
                    bll = new DeviceBLL();
                    CallContext.SetData(typeof(DeviceBLL).Name, bll);
                    return bll;
                }
            }
        }

        /// <summary>
        /// 獲取相關類型和消息的設備號碼
        /// </summary>
        public string[] GetDeviceList(int Type, int Mid)
        {
            return childDAL.GetDeviceList(Type, Mid);
        }

        /// <summary>
        /// 獲取需要推送的消息以及設備
        /// </summary>
        public int UpDateStatus(int mId, string token)
        {
            return childDAL.UpDateStatus(mId, token);
        }

        /// <summary>
        /// 推送失败时加上次数
        /// </summary>
        public int UpdateCount(int mId, string token)
        {
            return childDAL.UpdateCount(mId, token);
        }

        #endregion
    }
}
